#include <iostream> 
#include <cstring> 
using namespace std;
int main(){
	string s1;
	cin>>s1;
	int l1 = s1.size(),l2 = l1;
	char s2[l1];
	for(int i = 0;i<l1;++i)
		s2[i] = s1[l1-i-1];
	int dp[l1+1][l2+1];
	memset(dp,0,sizeof(dp));
	for(int i = 1;i<=l1;++i)
		for(int j = 1;j<=l2;++j)
		if(s1[i-1]==s2[j-1])
		dp[i][j] = dp[i-1][j-1]+1;
	else 
		dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
	cout<<l1-dp[l1][l2];
	return 0;
	
}